<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #btn {
            width: 100px;
            height: 100px;
            position: fixed;
            top: 0px;
        }

        #img {
            height: 600px;
        }
    </style>

</head>

<body>
    <img src="../day01/作业/img/bright.jpg" alt="" id="img">
    <button id="btn">关灯</button>
    <script>
        var img = document.getElementById('img');
        var btn = document.getElementById('btn');
        var flag = true;
        btn.onclick = function () {
            if (flag) {
                img.src = "../day01/作业/img/dark.jpg"
                btn.innerText = "开灯"
                flag = false;
            } else {
                img.src = "../day01/作业/img/bright.jpg"
                btn.innerText = "关灯"
                flag = true;
            }
        }
    </script>
</body>

</html>